home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Programmer's Power Pack
/
Delphi Volume 1.iso
/
e_to_l
/
isamexpt
/
isamtabl.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-09-15
|
63KB
|
2,056 lines
unit Isamtabl;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, DsgnIntf,
UUseIsam, Filer, LowBrows,
Restruct, ReIndex, ExtCtrls;
type
TIsamProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValueList(List: TStrings); virtual; abstract;
procedure GetValues(Proc: TGetStrProc); override;
end;
TIsamBrowserProperty = class(TIsamProperty)
procedure GetValueList(List: TStrings); override;
end;
TIsamHeaderProperty = class(TIsamProperty)
procedure GetValueList(List: TStrings); override;
end;
TIsamTable = class(TComponent)
private
FActive : Boolean;
FAnsiConvert : Boolean;
FTableName : TFileName;
FUnitName : TFileName;
FIsamKey : TStringList;
FRecordName : String;
FRecord : TStringList;
FIID : TStringList;
FNetz : NetSupportType;
FSaveModus : Boolean;
FSourceCreate: Boolean;
FBrowserName : String;
FHeaderName : String;
Procedure MySave;
Function Check(Name : String; SS : TStringList) : Boolean;
procedure CheckInactive;
function GetActive: Boolean;
procedure SetActive(Value: Boolean);
procedure SetTableName(const Value: TFileName);
procedure SetRecordName(const Value: String);
Procedure SetUnitName(const Value: TFileName);
{$IFDEF CodeGen}
Procedure Uses_Einfuegen(var SourceStrings: TStringList);
Procedure Record_Einfuegen(var SourceStrings: TStringList);
Procedure Data_Einfuegen(var SourceStrings: TStringList);
Procedure Key_Deklaration_Einfuegen(var SourceStrings: TStringList);
Procedure Key_Proc_Einfuegen(var SourceStrings: TStringList);
Procedure FormCreate_Einfuegen(var SourceStrings: TStringList);
Procedure FormCreate_Fuellen(var SourceStrings: TStringList);
Procedure FormResize_Fuellen(var SourceStrings: TStringList);
Procedure FormShow_Fuellen(var SourceStrings: TStringList);
Procedure HeaderCreate_Einfuegen(var SourceStrings: TStringList);
Procedure Browser_BuildRow_Einfuegen(var SourceStrings: TStringList);
Procedure Browser_Edit_Einfuegen(var SourceStrings: TStringList);
Procedure Klammern_Loeschen(var SourceStrings: TStringList);
{$ENDIF}
Procedure SetHeaderName(const Value: String);
Procedure SetBrowserName(const Value: String);
{$IFDEF CodeGen}
Procedure SetSourceCreate(const Value: Boolean);
{$ENDIF}
Function GetFormName(SList: TStringList): String;
protected
Procedure SetRecord(Value: TStringList);
Procedure SetKeyProc(Value: TStringList);
Procedure SetIIDProc(Value: TStringList);
Procedure SetNetz(Value: NetSupportType);
{$IFDEF CodeGen}
Procedure BrowRow(Var SListe: TStringList;Var II : Integer);
Procedure GetFeldProc_Einfuegen(var SourceStrings : TStringList);
{$ENDIF}
Procedure SetAnsiConvert(Const Value: Boolean);
public
IFBPtr : IsamFileBlockPtr;
Key_Proc : KeyProc;
RecSize : Longint;
KeyNo : Integer;
Ref : Longint;
Key : IsamKeyStr;
MaxKeys : Byte;
IID : IsamIndDescr;
EditFormIdent: String;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
Procedure Open;
Procedure Close;
Procedure ClearFields(var DATA,DUP);
Procedure Delete(var DATA,DUP);
Procedure Insert(var DATA,DUP);
Procedure Append(var DATA,DUP);
Procedure UpdateRecord(var DATA, DUP);
Procedure Get(var DATA, DUP);
Procedure Next(var DATA,DUP);
Function FindKey(Var Data,Dup;var Key1 : IsamKeyStr) : Boolean;
Function FindNearest(Var Data,Dup; Key1 : IsamKeyStr) : Boolean;
Procedure Prior(var DATA,DUP);
Procedure First(var DATA,DUP);
Procedure Last(var DATA,DUP);
Procedure CreateTable;
Function Rebuild: LongInt;
Function RecordCount: Longint;
published
property Active: Boolean read GetActive write SetActive default False;
Property AnsiConvert: Boolean read FAnsiConvert write SetAnsiConvert default True;
Property BrowserName: String read FBrowserName write SetBrowserName;
Property HeaderName: String read FHeaderName write SetHeaderName;
Property MyUnitName : TFileName read FUnitName write SetUnitName;
property TableName: TFileName read FTableName write SetTableName;
property RecordName: String read FRecordName write SetRecordName;
property IsamKeyProc: TStringList read FIsamKey write SetKeyProc;
property IsamRecord: TStringList read FRecord write SetRecord;
property Netz: NetSupportType read FNetz write SetNetz default NoNet;
property SaveModus: Boolean read FSaveModus write FSaveModus default False;
{$IFDEF CodeGen}
property SourceCreate: Boolean read FSourceCreate write SetSourceCreate default False;
{property SourceEditorCreate: Boolean read FEditorCreate write SetEditorCreate default False;}
{$ENDIF}
property AnzahlKeys: Byte read MaxKeys write MaxKeys default 1;
property IIDProc : TStringList read FIID write SetIIDProc;
end;
var NetType: NetSupportType;
implementation
Uses UToolDll, ExptIntf,
FvcBrows, IsamBrow, Proxies, Dat;
var FHandle: Longint;
MyNet : NetSupportType;
function TIsamProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList, paSortList, paMultiSelect, paReadOnly];
end;
procedure TIsamProperty.GetValues(Proc: TGetStrProc);
var
I: Integer;
Values: TStringList;
begin
Values := TStringList.Create;
try
GetValueList(Values);
for I := 0 to Values.Count - 1 do Proc(Values[I]);
finally
Values.Free;
end;
end;
procedure TIsamBrowserProperty.GetValueList(List: TStrings);
var I: Integer;
Component: TComponent;
begin
i:= 0;
While I < Designer.Form.ComponentCount do begin
Component := Designer.Form.Components[I];
if (Component is TIsamBrowser)
and (Component.Name <> '') then List.Add(Component.Name);
Inc(i);
end;
end;
procedure TIsamHeaderProperty.GetValueList(List: TStrings);
var I: Integer;
Component: TComponent;
begin
i:= 0;
While I < Designer.Form.ComponentCount do begin
Component := Designer.Form.Components[I];
if (Component is THeader) and (Component.Name <> '') then List.Add(Component.Name);
Inc(i);
end;
end;
constructor TIsamTable.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FAnsiConvert:= True;
IFBPTR:= NIL;
RecSize:= 0;
KeyNo:= 1;
Ref:= 0;
Key_Proc:= NIL;
FTableName:= '';
FRecordName:= '';
MaxKeys := 1;
FIsamKey:= TStringList.Create;
FRecord:= Tstringlist.create;
FIID := TStringList.Create;
{$Ifdef Test}
FIsamKey.Add('Function '+FRecordName+'KeyProc(Var Daten; KeyNr:Word): IsamKeyStr;');
FIsamKey.Add('var s : String;');
FIsamKey.Add('begin');
FIsamKey.Add(' s:= '+Chr(39)+Chr(39)+';');
FIsamKey.Add(' with '+FRecordName+'(Daten) do begin');
FIsamKey.Add(' case KeyNr of');
FIsamKey.Add(' 1 : S:= '+Chr(39)+Chr(39)+';');
FIsamKey.Add(' End;');
FIsamkey.Add(' end;');
FIsamKey.Add(' KeyProc:= s;');
FIsamkey.Add('end;');
FIsamkey.Add('');
FRecord.Add('Type');
FRecord.Add(FRecordName+' = Record');
FRecord.add(' Dummy : Longint;');
FRecord.add('end;');
{$Endif}
if (csDesigning in ComponentState) then
if Toolservices <> NIL then
begin
FIsamKey.Add('Function '+FRecordName+'KeyProc(Var Daten; KeyNr:Word): IsamKeyStr;');
FIsamKey.Add('var s : String;');
FIsamKey.Add('begin');
FIsamKey.Add(' s:= '+Chr(39)+Chr(39)+';');
FIsamKey.Add(' with '+FRecordName+'(Daten) do begin');
FIsamKey.Add(' case KeyNr of');
FIsamKey.Add(' 1 : S:= '+Chr(39)+Chr(39)+';');
FIsamKey.Add(' End;');
FIsamkey.Add(' end;');
FIsamKey.Add(' KeyProc:= s;');
FIsamkey.Add('end;');
FIsamkey.Add('');
FRecord.Add('Type');
FRecord.Add(FRecordName+' = Record